﻿Imports BUS, DTO
Public Class frmcapnhattacgia
    Private Sub LoadTacGia()
        dgvDanhSachTacGia.Rows.Clear()
        Dim bus As New TacGiaBUS()
        Dim dsTG As New List(Of TacGiaDTO)
        dsTG = bus.LayDSTacGia()

        For i As Integer = 0 To dsTG.Count - 1
            dgvDanhSachTacGia.Rows.Add(dsTG(i).MaTacGia, dsTG(i).TenTacGia)
        Next
    End Sub
    Private Sub frmcapnhattacgia_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadTacGia()
    End Sub

    Private Sub SimpleButton_CapNhat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton_CapNhat.Click
        If dgvDanhSachTacGia.CurrentRow.Index >= 0 Then
            Dim frm As New frmxlcapnhattacgia()
            frm.MaTacGia = dgvDanhSachTacGia.Item(0, dgvDanhSachTacGia.CurrentRow.Index).Value
            If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
                LoadTacGia()
            End If
        Else
            MessageBox.Show("Chưa chọn tác giả !")
        End If
    End Sub
End Class